/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tabelmodel;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import model.Yudisium;

/**
 *
 * @author admin
 */
public class TabelModelYudisium extends AbstractTableModel {

    private List<Yudisium> contents = new ArrayList<Yudisium>();

    public TabelModelYudisium(List<Yudisium> cont) {
        int row = cont.size();
        for (int i = 0; i < row; i++) {
            Yudisium me = (Yudisium) cont.get(i);
            contents.add(me);
        }
    }

    public void addYudisium(Yudisium me) {
        contents.add(me);
        fireTableRowsInserted(getRowCount(), getColumnCount());
    }

    public void removeYudisium(int i, int row) {
        contents.remove(i);
        fireTableRowsInserted(i, row);
    }

    public Yudisium getYudisium(int index) {
        return (Yudisium) contents.get(index);
    }

    @Override
    public int getRowCount() {
        return contents.size();
    }

    @Override
    public int getColumnCount() {
        return 5;
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "Nim";
            case 1:
                return "Nama";
            case 2:
                return "Nrodi";
            case 3:
                return "Nomor HP";
            case 4:
                return "Periode";
            default:
                return null;
        }
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return contents.get(rowIndex).getNim();
            case 1:
                return contents.get(rowIndex).getNama();
            case 2:
                return contents.get(rowIndex).getProdi();
            case 3:
                return contents.get(rowIndex).getNomor_hp();
            case 4:
                return contents.get(rowIndex).getPeriode_yudisium();
            default:
                return null;
        }
    }
}
